<#if formField.hidden?? && formField.hidden=="1">
<input type=hidden name="fieldMap['${field.name}'].id"  <#if businessInstanceField?? && businessInstanceField.id??>value="${businessInstanceField.id}"</#if>>
<input type=hidden name="fieldMap['${field.name}'].field.id"  value="${formField.field.id}">
<input type=hidden id=${field.name} name="fieldMap['${field.name}'].value" <#if businessInstanceField??>value="${businessInstanceField.value?default('')}" </#if>></input>
<#else>
<#if formField.readonly?? && formField.readonly=="1">
<#if businessInstanceField?? && businessInstanceField.displayValue??>${businessInstanceField.displayValue}</#if>
<#else>
<input type=hidden name="fieldMap['${field.name}'].id"  <#if businessInstanceField?? && businessInstanceField.id??>value="${businessInstanceField.id}"</#if>>
<input type=hidden name="fieldMap['${field.name}'].field.id"  value="${formField.field.id}">
<input type="text"   <#if fieldrule??> datarule="${fieldrule.dataType}"   datarulejson='${fieldrule.json}'  </#if>  readonly="readonly" id="${field.name}Id" name="${field.name}Names" class="textTest"  <#if businessInstanceField?? && businessInstanceField.displayValue??>value="${businessInstanceField.displayValue}" </#if>>
<input type="hidden" id="${field.name}" name="fieldMap['${field.name}'].value"  <#if businessInstanceField?? && businessInstanceField.value??>value="${businessInstanceField.value}" </#if> > </input>

<div id="contentDiv_company" class="dropDD_contentDiv">
	<div style="overflow:auto;height:266px">
		<ul id="companyTree${formField.orderNumber}" class="tree"></ul>			
	</div>
	<div class="buttonBox" style="position:absolute;bottom:0px;background:#f3f4f4;height:30px;padding-top:4px">
		<a href="#" class="button" tabindex="-1">
		<input type="button" onclick="saveNodes${formField.orderNumber}();return false;" style="width:80px" value="确认">
		</a>
		&nbsp;&nbsp;
		<a href="javascript:void(0);" class="button" tabindex="-1">
		<input type="button" onclick="clearCheckbox${formField.orderNumber}();return false;" style="width:80px" value="清空">
		</a>
	</div>
</div>		
<script language="JavaScript">
var treeObject${formField.orderNumber};
var elParent_company;
var cloneEl_company;
var setting${formField.orderNumber} = {
		asyncUrl : TDQS.CONTEXT_PATH+"company/children.action", //获取节点数据的URL地址
		asyncParam : ["id"],
		checkable: true,
		async : true,
		checkedCol : "checked",
		checkType: {
				"Y": "s",
				"N": "s"
			},
		callback : {
			click : function(event, treeId, treeNode) {
				treeNode[setting${formField.orderNumber}.checkedCol] = !treeNode[setting${formField.orderNumber}.checkedCol];
				treeObject${formField.orderNumber}.updateNode(treeNode,false);
			},// 点击每个节点的事件:
			loadTreeSuccess : function(zTree, msg) {		
				treeObject${formField.orderNumber} = zTree;
				//zTree.expandAll();
				var nodes = zTree.setting.root['nodes'];
				for(var i=0;i<nodes.length;i++) {
					zTree.expandNode(nodes[i],true,false);
				}
				if($(document.getElementById('${field.name}')).val()!='') {
					var nodes = zTree.setting.root['nodes'];
					preSelectNode${formField.orderNumber}(zTree,nodes);
				}
			}
		}
	};
$(document).ready(function(){
	 $(document.getElementById('${field.name}Id')).inputStyle({
		operatorId:"companyMenuBtn${formField.orderNumber}",
		operatorType:"text",
		operatorText:"选择",
		controllerWidth:'${formField.width?default('200')}',
		operatorFun:showMenu${formField.orderNumber},
		imgFun:clearCheckbox${formField.orderNumber}
	});


	<#if formField.width??>
	if("${formField.width?default('200')}".indexOf("px") >0){
		var w = parseFloat("${formField.width?default('200')}".replace("px",""));
       		$(document.getElementById("${field.name}Id")).css("width",w-16);
	}
	</#if>


});

function preSelectNode${formField.orderNumber}(zTree,nodes) {
	var value = $(document.getElementById('${field.name}')).val();
	var ids = value.split(",");
	for(var i=0;i<nodes.length;i++) {
  		if(nodes[i] && nodes[i].id){
  			var exists = false;
  			for(var j=0;j<ids.length;j++) {
  				if(nodes[i].id==ids[j]) {
  					exists = true;
  				}
  			}
  			if(exists) {
  				nodes[i][setting${formField.orderNumber}.checkedCol] = !nodes[i][setting${formField.orderNumber}.checkedCol];
					zTree.updateNode(nodes[i],false);
			  	zTree.expandNode(nodes[i],true,true);
  			}
  			if(nodes[i]['nodes'] && nodes[i]['nodes'].length>0) {
		  			preSelectNode${formField.orderNumber}(zTree,nodes[i]['nodes']);
		  	}
  		}
	}
}

function cancelOperate${formField.orderNumber}(){
	window.curDDWin.closeWin();
}
	
function showMenu${formField.orderNumber}()
{
	popDD();
}

function saveNodes${formField.orderNumber}() {
	var nodes = treeObject${formField.orderNumber}.getCheckedNodes(true);
	var ids = '';
	var names = '';
	for (var i=0, l=nodes.length; i<l; i++) {
		ids += nodes[i].id+",";
		names += nodes[i].name+",";
	}
	if(ids!='') {
		ids = ids.substring(0,ids.length-1);
	}
	if(names!='') {
		names = names.substring(0,names.length-1);
	}
	$(document.getElementById('${field.name}Id')).val(names);
	$(document.getElementById('${field.name}')).val(ids);
	window.curDDWin.saveWin();
}

function clearCheckbox${formField.orderNumber}(){
	//treeObject${formField.orderNumber}.cancelSelectedNode();
	$(document.getElementById('${field.name}')).val("");
	$(document.getElementById('${field.name}Id')).val("");
	//treeObject${formField.orderNumber} = $("#companyTree${formField.orderNumber}").zTree(setting${formField.orderNumber});
	treeObject${formField.orderNumber}.checkAllNodes(false);
	window.curDDWin.saveWin();
}


function popDD(){
if(!treeObject${formField.orderNumber}) {
	treeObject${formField.orderNumber} = $("#companyTree${formField.orderNumber}").zTree(setting${formField.orderNumber});
}
$("input[type='button']",$('.dropDD_contentDiv')).each(function(){
						this.style.backgroundImage="url(./../theme/default/images/main/btn_normal.png)";
						$(this).hover(function(){this.style.backgroundImage="url(./../theme/default/images/main/btn_over.png)";},function(){this.style.backgroundImage="url(./../theme/default/images/main/btn_normal.png)";});
					});
	new DDWin({
		el:'contentDiv_company'
		,dep:'divAround_${field.name}Id'
		,clickBody:'save'
	})
}
</script>
</#if>
</#if>